button box: Set linked style for extend
authorMatthias Clasen <mclasen@redhat.com>
Fri, 17 Jan 2014 17:39:30 +0000 (12:39 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 17 Jan 2014 22:52:07 +0000 (17:52 -0500)
This is needed for proper styling of the new extend-placement
in button boxes.

gtk/gtkbbox.c

index becdca2fbacd785bef1aca018a33617f9be046a3..58bed648075ebdfa9baa7663aa82c621c4caf129 100644 (file)
@@ -132,6 +132,13 @@ static void gtk_button_box_get_child_property (GtkContainer      *container,
 
 G_DEFINE_TYPE_WITH_PRIVATE (GtkButtonBox, gtk_button_box, GTK_TYPE_BOX)
 
+static void
+gtk_button_box_add (GtkContainer *container,
+                    GtkWidget    *widget)
+{
+  gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+}
+
 static void
 gtk_button_box_class_init (GtkButtonBoxClass *class)
 {
@@ -154,6 +161,7 @@ gtk_button_box_class_init (GtkButtonBoxClass *class)
   widget_class->size_allocate = gtk_button_box_size_allocate;
 
   container_class->remove = gtk_button_box_remove;
+  container_class->add = gtk_button_box_add;
   container_class->set_child_property = gtk_button_box_set_child_property;
   container_class->get_child_property = gtk_button_box_get_child_property;
   gtk_container_class_handle_border_width (container_class);
@@ -349,10 +357,18 @@ gtk_button_box_set_layout (GtkButtonBox      *widget,
   if (priv->layout_style != layout_style)
     {
       priv->layout_style = layout_style;
+
       if (priv->layout_style == GTK_BUTTONBOX_EXPAND)
-        gtk_box_set_homogeneous (GTK_BOX (widget), TRUE);
+        {
+          gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (widget)), "linked");
+          gtk_box_set_homogeneous (GTK_BOX (widget), TRUE);
+        }
       else
-        gtk_box_set_homogeneous (GTK_BOX (widget), FALSE);
+        {
+          gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (widget)), "linked");
+          gtk_box_set_homogeneous (GTK_BOX (widget), FALSE);
+        }
+
       g_object_notify (G_OBJECT (widget), "layout-style");
       gtk_widget_queue_resize (GTK_WIDGET (widget));
     }
@@ -435,8 +451,7 @@ gtk_button_box_set_child_secondary (GtkButtonBox *widget,
 
   if (bbox->priv->layout_style == GTK_BUTTONBOX_EXPAND)
     {
-      gtk_box_set_child_packing (GTK_BOX (bbox), child, TRUE, TRUE, 0,
-                                 is_secondary ? GTK_PACK_START : GTK_PACK_END);
+      gtk_box_reorder_child (GTK_BOX (bbox), child, is_secondary ? 0 : -1);
     }
 
   if (gtk_widget_get_visible (GTK_WIDGET (widget)) &&